#include <stdio.h>
/* pass an array to a function */
void display(int arr[]);
int main(int argc, char* argv[]){
int numbers[3];
numbers[0] = 23;
numbers[1] = 43;
numbers[2] = 36;
display(numbers);
return 0;
}
void display(int arr[]){
printf("\nvalue 1 is %d\n",arr[0]);
printf("\nvalue 2 is %d\n",arr[1]);
printf("\nvalue 3 is %d\n",arr[2]);
}
Compiling and running the program gives the following output:
secondhalf-lm:junk clacy$ gcc array.c -o array && ./array
value 1 is 23
value 2 is 43
value 3 is 36
christo